package com.team7.happycommunity.businessservice.service.impl;

import com.team7.happycommunity.businessservice.dao.ServiceOrderDao;
import com.team7.happycommunity.businessservice.entity.OrderClassify;
import com.team7.happycommunity.businessservice.entity.OrderDetails;
import com.team7.happycommunity.businessservice.entity.ServiceOrder;
import com.team7.happycommunity.businessservice.service.ServiceOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ServiceOrder)表服务实现类
 *
 * @author makejava
 * @since 2020-03-28 10:41:54
 */
@Service("serviceOrderService")
public class ServiceOrderServiceImpl implements ServiceOrderService {
    @Resource
    private ServiceOrderDao serviceOrderDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ServiceOrder queryById(Integer id) {
        return this.serviceOrderDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ServiceOrder> queryAllByLimit(int offset, int limit) {
        return this.serviceOrderDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param serviceOrder 实例对象
     * @return 实例对象
     */
    @Override
    public ServiceOrder insert(ServiceOrder serviceOrder) {
        this.serviceOrderDao.insert(serviceOrder);
        return serviceOrder;
    }

    /**
     * 修改数据
     *
     * @param serviceOrder 实例对象
     * @return 实例对象
     */
    @Override
    public ServiceOrder update(ServiceOrder serviceOrder) {
        this.serviceOrderDao.update(serviceOrder);
        return this.queryById(serviceOrder.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.serviceOrderDao.deleteById(id) > 0;
    }
    @Override
    public List<OrderClassify> queryOrderByUserIdAndStatus(Integer userId, Integer status){
        return serviceOrderDao.queryOrderByUserIdAndStatus(userId, status);
    }

    @Override
    public  void updateById(Integer id, Integer status){
        serviceOrderDao.updateById(id, status);
    }

    @Override
    public OrderDetails queryOrder(Integer orderId) {
        return serviceOrderDao.queryOrder(orderId);
    }

    @Override
    public List<OrderDetails> queryImage(Integer orderId) {
        return serviceOrderDao.queryImage(orderId);
    }

    @Override
    public List<OrderDetails> evaluate(Integer orderId) {
        return serviceOrderDao.evaluate(orderId);
    }
}